/*
2021-11-8
https://ac.nowcoder.com/acm/contest/22551/D
*/
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;
int a[100005];
int cnt[100005];

int main()
{
    int n, k;
    ll ans = 0;
    ll sum = 0;
    cin >> n >> k;
    cnt[0] = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
        sum %= k;
        cnt[sum]++;
        ans += cnt[sum] - 1;
    }

    cout << ans << endl;
    return 0;
}